package com.goldman.oss.common;


import com.goldman.oss.common.internal.processor.DownloadProcessor;
import com.goldman.oss.common.internal.processor.UploadProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;


@Slf4j
public class FileStorageProcessorFactory {
    public static UploadProcessor ofUpload(MultipartFile file) {
        UploadProcessor processor = new UploadProcessor();
        processor.setSize(file.getSize());
        processor.setOriginalFilename(file.getOriginalFilename());
        processor.setMultipartFile(file);
        return processor;
    }

    public static UploadProcessor ofUpload(File file) {
        UploadProcessor processor = new UploadProcessor();
        processor.setSize(file.length());
        processor.setOriginalFilename(file.getName());
        processor.setFile(file);
        return processor;
    }

    public static DownloadProcessor ofDownload() {
        return new DownloadProcessor();
    }

}
